<!DOCTYPE html>


<html theme="dark" showBanner="true" hasBanner="false" > 
<link href="https://cdn.staticfile.org/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet">
<link href="https://cdn.staticfile.org/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet">
<link href="https://cdn.staticfile.org/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet">
<script src="/hexo-blog/js/color.global.min.js" ></script>
<script src="/hexo-blog/js/load-settings.js" ></script>
<head>
  <meta charset="utf-8">
  
  
  

  
  <title>CSS函数大全（三）：颜色、渐变和滤镜 | bressanone</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

  <link rel="preload" href="/hexo-blog/css/fonts/Roboto-Regular.ttf" as="font" type="font/ttf" crossorigin="anonymous">
  <link rel="preload" href="/hexo-blog/css/fonts/Roboto-Bold.ttf" as="font" type="font/ttf" crossorigin="anonymous">

  <meta name="description" content="这是我参与11月更文挑战的第26天，活动详情查看：2021最后一次更文挑战 本系列目标是做一个css函数完全指南，将尽可能罗列css中所有的函数及其用法，当需要使用或者理解某个css函数的时候，只要来这里寻找就可以了。 颜色rgb和rgba前三个参数分别是红、绿、蓝色值。 12345.el &#123;     color: rgb(255, 0, 0);     color: rgba(255,">
<meta property="og:type" content="article">
<meta property="og:title" content="CSS函数大全（三）：颜色、渐变和滤镜">
<meta property="og:url" content="http://example.com/2021/11/26/CSS%E5%87%BD%E6%95%B0%E5%A4%A7%E5%85%A8%EF%BC%88%E4%B8%89%EF%BC%89%EF%BC%9A%E9%A2%9C%E8%89%B2%E3%80%81%E6%B8%90%E5%8F%98%E5%92%8C%E6%BB%A4%E9%95%9C/index.html">
<meta property="og:site_name" content="bressanone">
<meta property="og:description" content="这是我参与11月更文挑战的第26天，活动详情查看：2021最后一次更文挑战 本系列目标是做一个css函数完全指南，将尽可能罗列css中所有的函数及其用法，当需要使用或者理解某个css函数的时候，只要来这里寻找就可以了。 颜色rgb和rgba前三个参数分别是红、绿、蓝色值。 12345.el &#123;     color: rgb(255, 0, 0);     color: rgba(255,">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/d2c1ca8234704e8cb918d7b53a008d00.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/79d57ee723c0414fa58067db9964da81.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/999db97b32c64a63b4411bda28308618.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/0d87ab8a99ff4cfba6d30dfbe2a4cc6b.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/77a53feae9054e88b68b47f8291f899d.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/e0c516bdfadb4be5b800d09bfce3e6b8.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/064dd050a8f644c0bcc6a3ff23565f97.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/279f927c1695458eb47fc01391cf08c2.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/54d69cada2784fccb0e1e17a443a57d2.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/006adce2e90d46b6bf6680421b8597fe.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/1b26737844194fc09f923cdd6b3b8a92.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/0f677483d57d40f69267e8e4ef2d3b0e.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/fab6f6cc9c23439fa4783422b7bd1784.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/bfb8a4db30f74136811c79d6a2063b74.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/8f0428ba4af94e59b6081a6b83759acd.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/d689027c2c594f89b566a1e2c5465887.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/f199300488514aa3847075b4b8541c02.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/14bc0f5d968347b3adbeeba4dab57aed.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/6966a88766614ea5a249363a6f129797.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/a3745c91af4948b8828204411aba625f.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/06bb1763a47148cc8c74ca46ec66fcbe.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/09ff6519ba1340db8b9a61ea480f57b0.png">
<meta property="og:image" content="http://example.com/2021/11/26/imgs/7ed844989c4640a9be7cc2922107c3d3.png">
<meta property="article:published_time" content="2021-11-25T16:00:00.000Z">
<meta property="article:modified_time" content="2024-04-13T12:20:29.580Z">
<meta property="article:author" content="Zachary">
<meta property="article:tag" content="前端">
<meta property="article:tag" content="CSS">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://example.com/2021/11/26/imgs/d2c1ca8234704e8cb918d7b53a008d00.png">
  
  
    <link rel="icon" media="(prefers-color-scheme: light)" href="/hexo-blog/images/favicon-light-32.png" sizes="32x32">
    <link rel="icon" media="(prefers-color-scheme: light)" href="/hexo-blog/images/favicon-light-128.png" sizes="128x128">
    <link rel="icon" media="(prefers-color-scheme: light)" href="/hexo-blog/images/favicon-light-180.png" sizes="180x180">
    <link rel="icon" media="(prefers-color-scheme: light)" href="/hexo-blog/images/favicon-light-192.png" sizes="192x192">
    <link rel="icon" media="(prefers-color-scheme: dark)" href="/hexo-blog/images/favicon-dark-32.png" sizes="32x32">
    <link rel="icon" media="(prefers-color-scheme: dark)" href="/hexo-blog/images/favicon-dark-128.png" sizes="128x128">
    <link rel="icon" media="(prefers-color-scheme: dark)" href="/hexo-blog/images/favicon-dark-180.png" sizes="180x180">
    <link rel="icon" media="(prefers-color-scheme: dark)" href="/hexo-blog/images/favicon-dark-192.png" sizes="192x192">
  
  
<link rel="stylesheet" href="/hexo-blog/css/style.css">

<meta name="generator" content="Hexo 7.1.1"></head>

<body>
  
   
  <div id="main-grid" class="  ">
    <div id="nav" class=""  >
      <navbar id="navbar">
  <nav id="title-nav">
    <a href="/hexo-blog/">
      <div id="vivia-logo">
        <div class="dot"></div>
        <div class="dot"></div>
        <div class="dot"></div>
        <div class="dot"></div>
      </div>
      <div>bressanone </div>
    </a>
  </nav>
  <nav id="main-nav">
    
      <a class="main-nav-link" href="/hexo-blog/">主页</a>
    
      <a class="main-nav-link" href="/hexo-blog/archives">归档</a>
    
      <a class="main-nav-link" href="/hexo-blog/about">关于</a>
    
  </nav>
  <nav id="sub-nav">
    <a id="theme-btn" class="nav-icon">
      <span class="light-mode-icon"><svg xmlns="http://www.w3.org/2000/svg" height="20" viewBox="0 -960 960 960" width="20"><path d="M438.5-829.913v-48q0-17.452 11.963-29.476 11.964-12.024 29.326-12.024 17.363 0 29.537 12.024t12.174 29.476v48q0 17.452-11.963 29.476-11.964 12.024-29.326 12.024-17.363 0-29.537-12.024T438.5-829.913Zm0 747.826v-48q0-17.452 11.963-29.476 11.964-12.024 29.326-12.024 17.363 0 29.537 12.024t12.174 29.476v48q0 17.452-11.963 29.476-11.964 12.024-29.326 12.024-17.363 0-29.537-12.024T438.5-82.087ZM877.913-438.5h-48q-17.452 0-29.476-11.963-12.024-11.964-12.024-29.326 0-17.363 12.024-29.537t29.476-12.174h48q17.452 0 29.476 11.963 12.024 11.964 12.024 29.326 0 17.363-12.024 29.537T877.913-438.5Zm-747.826 0h-48q-17.452 0-29.476-11.963-12.024-11.964-12.024-29.326 0-17.363 12.024-29.537T82.087-521.5h48q17.452 0 29.476 11.963 12.024 11.964 12.024 29.326 0 17.363-12.024 29.537T130.087-438.5Zm660.174-290.87-34.239 32q-12.913 12.674-29.565 12.174-16.653-.5-29.327-13.174-12.674-12.673-12.554-28.826.12-16.152 12.794-28.826l33-35q12.913-12.674 30.454-12.674t30.163 12.847q12.709 12.846 12.328 30.826-.38 17.98-13.054 30.653ZM262.63-203.978l-32 34q-12.913 12.674-30.454 12.674t-30.163-12.847q-12.709-12.846-12.328-30.826.38-17.98 13.054-30.653l33.239-31q12.913-12.674 29.565-12.174 16.653.5 29.327 13.174 12.674 12.673 12.554 28.826-.12 16.152-12.794 28.826Zm466.74 33.239-32-33.239q-12.674-12.913-12.174-29.565.5-16.653 13.174-29.327 12.673-12.674 28.826-13.054 16.152-.38 28.826 12.294l35 33q12.674 12.913 12.674 30.454t-12.847 30.163q-12.846 12.709-30.826 12.328-17.98-.38-30.653-13.054ZM203.978-697.37l-34-33q-12.674-12.913-13.174-29.945-.5-17.033 12.174-29.707t31.326-13.293q18.653-.62 31.326 13.054l32 34.239q11.674 12.913 11.174 29.565-.5 16.653-13.174 29.327-12.673 12.674-28.826 12.554-16.152-.12-28.826-12.794ZM480-240q-100 0-170-70t-70-170q0-100 70-170t170-70q100 0 170 70t70 170q0 100-70 170t-170 70Zm-.247-82q65.703 0 111.475-46.272Q637-414.544 637-480.247t-45.525-111.228Q545.95-637 480.247-637t-111.475 45.525Q323-545.95 323-480.247t45.525 111.975Q414.05-322 479.753-322ZM481-481Z"/></svg></span>
      <span class="dark-mode-icon"><svg xmlns="http://www.w3.org/2000/svg" height="20" viewBox="0 -960 960 960" width="20"><path d="M480.239-116.413q-152.63 0-258.228-105.478Q116.413-327.37 116.413-480q0-130.935 77.739-227.435t206.304-125.043q43.022-9.631 63.87 10.869t3.478 62.805q-8.891 22.043-14.315 44.463-5.424 22.42-5.424 46.689 0 91.694 64.326 155.879 64.325 64.186 156.218 64.186 24.369 0 46.978-4.946 22.609-4.945 44.413-14.076 42.826-17.369 62.967 1.142 20.142 18.511 10.511 61.054Q807.174-280 712.63-198.206q-94.543 81.793-232.391 81.793Zm0-95q79.783 0 143.337-40.217 63.554-40.218 95.793-108.283-15.608 4.044-31.097 5.326-15.49 1.283-31.859.805-123.706-4.066-210.777-90.539-87.071-86.473-91.614-212.092-.24-16.369.923-31.978 1.164-15.609 5.446-30.978-67.826 32.478-108.282 96.152Q211.652-559.543 211.652-480q0 111.929 78.329 190.258 78.329 78.329 190.258 78.329ZM466.13-465.891Z"/></svg></span>
    </a>
    
    <div id="nav-menu-btn" class="nav-icon">
      <svg xmlns="http://www.w3.org/2000/svg" height="20" viewBox="0 -960 960 960" width="20"><path d="M177.37-252.282q-17.453 0-29.477-11.964-12.024-11.963-12.024-29.326t12.024-29.537q12.024-12.174 29.477-12.174h605.26q17.453 0 29.477 11.964 12.024 11.963 12.024 29.326t-12.024 29.537q-12.024 12.174-29.477 12.174H177.37Zm0-186.218q-17.453 0-29.477-11.963-12.024-11.964-12.024-29.326 0-17.363 12.024-29.537T177.37-521.5h605.26q17.453 0 29.477 11.963 12.024 11.964 12.024 29.326 0 17.363-12.024 29.537T782.63-438.5H177.37Zm0-186.217q-17.453 0-29.477-11.964-12.024-11.963-12.024-29.326t12.024-29.537q12.024-12.174 29.477-12.174h605.26q17.453 0 29.477 11.964 12.024 11.963 12.024 29.326t-12.024 29.537q-12.024 12.174-29.477 12.174H177.37Z"/></svg>
    </div>
  </nav>
</navbar>
<div id="nav-dropdown" class="hidden">
  <div id="dropdown-link-list">
    
      <a class="nav-dropdown-link" href="/hexo-blog/">主页</a>
    
      <a class="nav-dropdown-link" href="/hexo-blog/archives">归档</a>
    
      <a class="nav-dropdown-link" href="/hexo-blog/about">关于</a>
    
     
    </div>
</div>
<script>
  let dropdownBtn = document.getElementById("nav-menu-btn");
  let dropdownEle = document.getElementById("nav-dropdown");
  dropdownBtn.onclick = function() {
    dropdownEle.classList.toggle("hidden");
  }
</script>
    </div>
    <div id="sidebar-wrapper">
      <sidebar id="sidebar">
  
    <div class="widget-wrap">
  <div class="info-card">
    <div class="avatar">
      
      <div class="img-dim"></div>
    </div>
    <div class="info">
      <div class="username">Zachary </div>
      <div class="dot"></div>
      <div class="subtitle"> </div>
      <div class="link-list">
        
          <a class="link-btn" target="_blank" rel="noopener" href="https://github.com/zzy1661" title="GitHub"><i class="fa-brands fa-github"></i></a>
         
      </div>  
    </div>
  </div>
</div>

  
  <div class="sticky">
    
      


  <div class="widget-wrap">
    <div class="widget">
      <h3 class="widget-title">分类</h3>
      <div class="category-box">
            <a class="category-link" href="/hexo-blog/categories/%E5%89%8D%E7%AB%AF%E7%AC%94%E8%AE%B0/">
                前端笔记
                <div class="category-count">78</div>
            </a>
        
            <a class="category-link" href="/hexo-blog/categories/%E7%AE%97%E6%B3%95%E6%89%8B%E5%86%8C/">
                算法手册
                <div class="category-count">7</div>
            </a>
        </div>
    </div>
  </div>


    
      
  <div class="widget-wrap">
    <div class="widget">
      <h3 class="widget-title">标签</h3>
      <ul class="widget-tag-list" itemprop="keywords"><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Ant-Design/" rel="tag">Ant Design</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/CSS/" rel="tag">CSS</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Canvas/" rel="tag">Canvas</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Docker/" rel="tag">Docker</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/ECMAScript-6/" rel="tag">ECMAScript 6</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/JavaScript/" rel="tag">JavaScript</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Less/" rel="tag">Less</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/MobX/" rel="tag">MobX</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/MongoDB/" rel="tag">MongoDB</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/NPM/" rel="tag">NPM</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/NestJS/" rel="tag">NestJS</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Node-js/" rel="tag">Node.js</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Postman/" rel="tag">Postman</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/React-js/" rel="tag">React.js</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Redux/" rel="tag">Redux</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/TypeScript/" rel="tag">TypeScript</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/UML/" rel="tag">UML</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Webpack/" rel="tag">Webpack</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Yeoman/" rel="tag">Yeoman</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/%E5%89%8D%E7%AB%AF/" rel="tag">前端</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/%E6%9E%B6%E6%9E%84/" rel="tag">架构</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/" rel="tag">正则表达式</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/%E6%BA%90%E7%A0%81/" rel="tag">源码</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/%E7%88%AC%E8%99%AB/" rel="tag">爬虫</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/%E7%AE%97%E6%B3%95/" rel="tag">算法</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/%E9%9D%A2%E8%AF%95/" rel="tag">面试</a></li></ul>
    </div>
  </div>


    
  </div>
</sidebar>
    </div>
    <div id="content-body">
       


<article id="post-CSS函数大全（三）：颜色、渐变和滤镜" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
  
    
   
  <div class="article-inner">
    <div class="article-main">
      <header class="article-header">
        
<div class="main-title-bar">
  <div class="main-title-dot"></div>
  
    
      <h1 class="p-name article-title" itemprop="headline name">
        CSS函数大全（三）：颜色、渐变和滤镜
      </h1>
    
  
</div>

        <div class='meta-info-bar'>
          <div class="meta-info">
  <time class="dt-published" datetime="2021-11-25T16:00:00.000Z" itemprop="datePublished">2021-11-26</time>
</div>
          <div class="need-seperator meta-info">
            <div class="meta-cate-flex">
  
  <a class="meta-cate-link" href="/hexo-blog/categories/%E5%89%8D%E7%AB%AF%E7%AC%94%E8%AE%B0/">前端笔记</a>
   
</div>
  
          </div>
          <div class="wordcount need-seperator meta-info">
            2.7k 词 
          </div>
        </div>
        
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/hexo-blog/tags/CSS/" rel="tag">CSS</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/hexo-blog/tags/%E5%89%8D%E7%AB%AF/" rel="tag">前端</a></li></ul>

      </header>
      <div class="e-content article-entry" itemprop="articleBody">
        
          <p>这是我参与11月更文挑战的第26天，活动详情查看：<a target="_blank" rel="noopener" href="https://juejin.cn/post/7023643374569816095" title="https://juejin.cn/post/7023643374569816095">2021最后一次更文挑战</a></p>
<p>本系列目标是做一个css函数完全指南，将尽可能罗列css中所有的函数及其用法，当需要使用或者理解某个css函数的时候，只要来这里寻找就可以了。</p>
<h2 id="颜色"><a href="#颜色" class="headerlink" title="颜色"></a>颜色</h2><h3 id="rgb和rgba"><a href="#rgb和rgba" class="headerlink" title="rgb和rgba"></a>rgb和rgba</h3><p>前三个参数分别是红、绿、蓝色值。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.el</span> &#123; </span><br><span class="line">    <span class="attribute">color</span>: <span class="built_in">rgb</span>(<span class="number">255</span>, <span class="number">0</span>, <span class="number">0</span>); </span><br><span class="line">    <span class="attribute">color</span>: <span class="built_in">rgba</span>(<span class="number">255</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0.5</span>); </span><br><span class="line">    <span class="attribute">color</span>: <span class="built_in">rgb</span>(<span class="number">255</span> <span class="number">0</span> <span class="number">0</span> / <span class="number">0.5</span>); </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="hsl和hsla"><a href="#hsl和hsla" class="headerlink" title="hsl和hsla"></a>hsl和hsla</h3><p>前三个参数分别是色调 ( <code>h</code>)、饱和度 ( <code>s</code>) 和亮度 ( <code>l</code>)</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.el</span> &#123;</span><br><span class="line">    <span class="attribute">background</span>: <span class="built_in">hsl</span>(<span class="number">100</span>, <span class="number">100%</span>, <span class="number">50%</span>);</span><br><span class="line">    <span class="attribute">background</span>: <span class="built_in">hsla</span>(<span class="number">100</span>, <span class="number">100%</span>, <span class="number">50%</span>, <span class="number">0.5</span>);</span><br><span class="line">    <span class="attribute">background</span>: <span class="built_in">hsl</span>(<span class="number">100</span> <span class="number">100%</span> <span class="number">50%</span> / <span class="number">0.5</span>);</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>

<p>按照<a href="https://www.w3.org%2FTR%2Fcss-color-4%2F" title="https://www.w3.org/TR/css-color-4/">css color level 4</a>，我们可以省略逗号，并用<code>/</code>隔开alpha。</p>
<h2 id="渐变"><a href="#渐变" class="headerlink" title="渐变"></a>渐变</h2><h4 id="linear-gradient-and-repeating-linear-gradient"><a href="#linear-gradient-and-repeating-linear-gradient" class="headerlink" title="linear-gradient() and repeating-linear-gradient()"></a><code>linear-gradient()</code> and <code>repeating-linear-gradient()</code></h4><p>在一条直线上创建多种颜色的渐变。</p>
<p>参数为</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">direction</span>, <span class="attribute">color</span>-stop1, <span class="attribute">color</span>-stop2, ...</span><br></pre></td></tr></table></figure>

<p>direction：用角度值指定渐变的方向（或角度）。</p>
<p>color-stop1, color-stop2, …： 用于指定渐变的起止颜色。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(<span class="number">#e66465</span>, <span class="number">#9198e5</span>);</span><br><span class="line"><span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(<span class="number">0.25turn</span>, <span class="number">#3f87a6</span>, <span class="number">#ebf8e1</span>, <span class="number">#f69d3c</span>);</span><br><span class="line"><span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(to left, <span class="number">#333</span>, <span class="number">#333</span> <span class="number">50%</span>, <span class="number">#eee</span> <span class="number">75%</span>, <span class="number">#333</span> <span class="number">75%</span>);</span><br><span class="line"><span class="attribute">background</span>: <span class="built_in">linear-gradient</span>(<span class="number">217deg</span>, <span class="built_in">rgba</span>(<span class="number">255</span>,<span class="number">0</span>,<span class="number">0</span>,.<span class="number">8</span>), <span class="built_in">rgba</span>(<span class="number">255</span>,<span class="number">0</span>,<span class="number">0</span>,<span class="number">0</span>) <span class="number">70.71%</span>), <span class="built_in">linear-gradient</span>(<span class="number">127deg</span>, <span class="built_in">rgba</span>(<span class="number">0</span>,<span class="number">255</span>,<span class="number">0</span>,.<span class="number">8</span>), <span class="built_in">rgba</span>(<span class="number">0</span>,<span class="number">255</span>,<span class="number">0</span>,<span class="number">0</span>) <span class="number">70.71%</span>), <span class="built_in">linear-gradient</span>(<span class="number">336deg</span>, <span class="built_in">rgba</span>(<span class="number">0</span>,<span class="number">0</span>,<span class="number">255</span>,.<span class="number">8</span>), <span class="built_in">rgba</span>(<span class="number">0</span>,<span class="number">0</span>,<span class="number">255</span>,<span class="number">0</span>) <span class="number">70.71%</span>);</span><br></pre></td></tr></table></figure>

<p><img src="./../imgs/d2c1ca8234704e8cb918d7b53a008d00.png" alt="image.png"></p>
<p>一个color-stop由一个color和两个可选的长度或百分比组成，代表这个颜色开始和结束的位置，如</p>
<figure class="highlight erlang"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">orange <span class="number">20</span><span class="comment">% 40%</span></span><br></pre></td></tr></table></figure>

<p>如果空间比渐变设置的更多，那么使用<code>repeating-linear-gradient</code>会创建重复渐变。比如下面的，从20%的位置开始将重复前面的渐变。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">background</span>: <span class="built_in">repeating-linear-gradient</span>(<span class="number">45deg</span>, <span class="number">#3f87a6</span>, <span class="number">#ebf8e1</span> <span class="number">15%</span>, <span class="number">#f69d3c</span> <span class="number">20%</span>);</span><br></pre></td></tr></table></figure>

<h4 id="radial-gradient-and-repeating-radial-gradient"><a href="#radial-gradient-and-repeating-radial-gradient" class="headerlink" title="radial-gradient() and repeating-radial-gradient()"></a><code>radial-gradient()</code> and <code>repeating-radial-gradient()</code></h4><p>创建径向渐变，它与线性渐变的不同点在于它是从中心点向外辐射。</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(<span class="number">#e66465</span>, <span class="number">#9198e5</span>);</span><br><span class="line"><span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(circle at <span class="number">100%</span>, <span class="number">#333</span>, <span class="number">#333</span> <span class="number">50%</span>, <span class="number">#eee</span> <span class="number">75%</span>, <span class="number">#333</span> <span class="number">75%</span>);</span><br><span class="line"><span class="attribute">background</span>: <span class="built_in">radial-gradient</span>(ellipse at top, <span class="number">#e66465</span>, transparent), <span class="built_in">radial-gradient</span>(ellipse at bottom, <span class="number">#4d9f0c</span>, transparent);</span><br></pre></td></tr></table></figure>

<p><img src="./../imgs/79d57ee723c0414fa58067db9964da81.png" alt="image.png"></p>
<p>参数为：</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">shape size at <span class="attribute">position</span>, start-<span class="attribute">color</span>, ..., last-<span class="attribute">color</span></span><br></pre></td></tr></table></figure>

<p>shape确定圆的类型，<code>circle</code>或<code>ellipse</code>,默认是<code>ellipse</code>。</p>
<p>size定义渐变的大小，可能的值为</p>
<ul>
<li><code>closest-side</code>:指定径向渐变的半径长度为从圆心到离圆心最近的边</li>
<li><code>closest-corner</code>:指定径向渐变的半径长度为从圆心到离圆心最近的角</li>
<li><code>farthest-side</code> : 指定径向渐变的半径长度为从圆心到离圆心最远的边</li>
<li><code>farthest-corner</code>:默认，指定径向渐变的半径长度为从圆心到离圆心最远的角 <code>repeating-radial-gradient</code>用于创建重复的径向渐变</li>
</ul>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">background</span>: <span class="built_in">repeating-radial-gradient</span>(<span class="number">#e66465</span>, <span class="number">#9198e5</span> <span class="number">20%</span>);</span><br></pre></td></tr></table></figure>

<h4 id="conic-gradient-and-repeating-conical-gradient"><a href="#conic-gradient-and-repeating-conical-gradient" class="headerlink" title="conic-gradient() and repeating-conical-gradient"></a><code>conic-gradient()</code> and <code>repeating-conical-gradient</code></h4><p>圆锥渐变与径向渐变的不同之处在于颜色围绕一个圆分布</p>
<figure class="highlight scss"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">conic-gradient</span>(red, orange, yellow, green, teal, blue, purple, red)</span><br></pre></td></tr></table></figure>

<p><img src="./../imgs/999db97b32c64a63b4411bda28308618.png" alt="image.png"></p>
<h2 id="滤镜filter"><a href="#滤镜filter" class="headerlink" title="滤镜filter"></a>滤镜filter</h2><h2 id="brightness"><a href="#brightness" class="headerlink" title="brightness()"></a><code>brightness()</code></h2><p>使内容看起来更亮或更暗</p>
<figure class="highlight scss"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">brightness</span>(amount)</span><br></pre></td></tr></table></figure>

<p>参数amount：[<code>&lt;number&gt;</code>]或[<code>&lt;percentage&gt;</code>]，低于1更暗，高于1更亮</p>
<figure class="highlight scss"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">brightness</span>(<span class="number">0%</span>)   <span class="comment">/* 全黑 */</span></span><br><span class="line"><span class="built_in">brightness</span>(<span class="number">0.4</span>)  <span class="comment">/* 40% 亮度 */</span></span><br></pre></td></tr></table></figure>

<p><img src="./../imgs/0d87ab8a99ff4cfba6d30dfbe2a4cc6b.png" alt="image.png"> <img src="./../imgs/77a53feae9054e88b68b47f8291f899d.png" alt="image.png"></p>
<h3 id="blur"><a href="#blur" class="headerlink" title="blur()"></a><code>blur()</code></h3><p>模糊图像</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">filter</span>: <span class="built_in">blur</span>(<span class="number">0</span>);</span><br><span class="line"><span class="attribute">filter</span>: <span class="built_in">blur</span>(<span class="number">4px</span>);</span><br></pre></td></tr></table></figure>

<p><img src="./../imgs/e0c516bdfadb4be5b800d09bfce3e6b8.png" alt="image.png"> <img src="./../imgs/064dd050a8f644c0bcc6a3ff23565f97.png" alt="image.png"></p>
<h3 id="contrast"><a href="#contrast" class="headerlink" title="contrast()"></a><code>contrast()</code></h3><p>增加或减少图像的对比度</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">filter</span>: <span class="built_in">contrast</span>(<span class="number">50%</span>);</span><br><span class="line"><span class="attribute">filter</span>: <span class="built_in">contrast</span>(<span class="number">1.75</span>);</span><br></pre></td></tr></table></figure>

<p><img src="./../imgs/279f927c1695458eb47fc01391cf08c2.png" alt="image.png"> <img src="./../imgs/54d69cada2784fccb0e1e17a443a57d2.png" alt="image.png"></p>
<h3 id="grayscale"><a href="#grayscale" class="headerlink" title="grayscale()"></a><code>grayscale()</code></h3><p>将图像转为灰度图</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">filter</span>: <span class="built_in">grayscale</span>(<span class="number">1</span>);</span><br><span class="line"><span class="attribute">filter</span>: <span class="built_in">grayscale</span>(<span class="number">0</span>);</span><br></pre></td></tr></table></figure>

<p><img src="./../imgs/006adce2e90d46b6bf6680421b8597fe.png" alt="image.png"> <img src="./../imgs/1b26737844194fc09f923cdd6b3b8a92.png" alt="image.png"></p>
<h3 id="invert"><a href="#invert" class="headerlink" title="invert()"></a><code>invert()</code></h3><p>反转图像颜色</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">filter</span>: <span class="built_in">invert</span>(<span class="number">0.30</span>);</span><br><span class="line"><span class="attribute">filter</span>: <span class="built_in">invert</span>(<span class="number">1</span>);</span><br></pre></td></tr></table></figure>

<p><img src="./../imgs/0f677483d57d40f69267e8e4ef2d3b0e.png" alt="image.png"> <img src="./../imgs/fab6f6cc9c23439fa4783422b7bd1784.png" alt="image.png"></p>
<h3 id="opacity"><a href="#opacity" class="headerlink" title="opacity()"></a><code>opacity()</code></h3><p>改变图像透明度</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">filter</span>: <span class="built_in">opacity</span>(<span class="number">0.20</span>);</span><br></pre></td></tr></table></figure>

<p><img src="./../imgs/bfb8a4db30f74136811c79d6a2063b74.png" alt="image.png"></p>
<h3 id="saturate"><a href="#saturate" class="headerlink" title="saturate()"></a><code>saturate()</code></h3><p>改变饱和度</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">filter</span>: <span class="built_in">saturate</span>(<span class="number">1</span>);</span><br><span class="line"><span class="attribute">filter</span>: <span class="built_in">saturate</span>(<span class="number">4</span>);</span><br><span class="line"><span class="attribute">filter</span>: <span class="built_in">saturate</span>(<span class="number">50%</span>);</span><br></pre></td></tr></table></figure>

<p><img src="./../imgs/8f0428ba4af94e59b6081a6b83759acd.png"> <img src="./../imgs/d689027c2c594f89b566a1e2c5465887.png"> <img src="./../imgs/f199300488514aa3847075b4b8541c02.png"></p>
<h3 id="sepia"><a href="#sepia" class="headerlink" title="sepia()"></a><code>sepia()</code></h3><p>棕褐色滤镜</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">filter</span>: <span class="built_in">sepia</span>(<span class="number">0.20</span>);</span><br><span class="line"><span class="attribute">filter</span>: <span class="built_in">sepia</span>(<span class="number">1</span>);</span><br></pre></td></tr></table></figure>

<p><img src="./../imgs/14bc0f5d968347b3adbeeba4dab57aed.png" alt="image.png"> <img src="./../imgs/6966a88766614ea5a249363a6f129797.png" alt="image.png"></p>
<h3 id="drop-shadow"><a href="#drop-shadow" class="headerlink" title="drop-shadow()"></a><code>drop-shadow()</code></h3><p>在图像后方应用投影,和<code>box-shadow</code>的不同之处在于，这个函数创建的投影是符合图像本身形状的，而<code>box-shadow</code>创建的是矩形阴影</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">filter</span>: <span class="built_in">drop-shadow</span>(<span class="number">30px</span> <span class="number">10px</span> <span class="number">4px</span> <span class="number">#4444dd</span>);</span><br><span class="line"><span class="attribute">filter</span>: <span class="built_in">drop-shadow</span>(<span class="number">0</span> -<span class="number">6mm</span> <span class="number">4mm</span> <span class="built_in">rgb</span>(<span class="number">160</span>, <span class="number">0</span>, <span class="number">210</span>));</span><br></pre></td></tr></table></figure>

<p><img src="./../imgs/a3745c91af4948b8828204411aba625f.png" alt="image.png"> <img src="./../imgs/06bb1763a47148cc8c74ca46ec66fcbe.png" alt="image.png"></p>
<h3 id="hue-rotate"><a href="#hue-rotate" class="headerlink" title="hue-rotate()"></a><code>hue-rotate()</code></h3><p>增加或降低色调</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="attribute">filter</span>: <span class="built_in">hue-rotate</span>(<span class="number">90deg</span>);</span><br><span class="line"><span class="attribute">filter</span>: <span class="built_in">hue-rotate</span>(-<span class="number">0.25turn</span>);</span><br></pre></td></tr></table></figure>

<p><img src="./../imgs/09ff6519ba1340db8b9a61ea480f57b0.png" alt="image.png"> <img src="./../imgs/7ed844989c4640a9be7cc2922107c3d3.png" alt="image.png"></p>

        
      </div>

         
    </div>
    
     
  </div>
  
    
<nav id="article-nav">
  <a class="article-nav-btn left "
    
      href="/hexo-blog/2021/11/27/CSS%E5%87%BD%E6%95%B0%E5%A4%A7%E5%85%A8%EF%BC%88%E5%9B%9B%EF%BC%89%EF%BC%9A%E6%9D%82%E9%A1%B9%E5%92%8C%E6%9C%AA%E6%9D%A5/"
      title="CSS函数大全（四）：杂项和未来"
     >
    <i class="fa-solid fa-angle-left"></i>
    <p class="title-text">
      
        CSS函数大全（四）：杂项和未来
        
    </p>
  </a>
  <a class="article-nav-btn right "
    
      href="/hexo-blog/2021/11/25/CSS%E5%87%BD%E6%95%B0%E5%A4%A7%E5%85%A8%EF%BC%88%E4%BA%8C%EF%BC%89%EF%BC%9A%E8%BD%AC%E6%8D%A2%E3%80%81%E5%8A%A8%E7%94%BB%E5%92%8C%E5%BD%A2%E7%8A%B6%20path/"
      title="CSS函数大全（二）：转换、动画和形状/path"
     >

    <p class="title-text">
      
        CSS函数大全（二）：转换、动画和形状/path
        
    </p>
    <i class="fa-solid fa-angle-right"></i>
  </a>
</nav>


  
</article>





    </div>
    <div id="footer-wrapper">
      <footer id="footer">
  
  <div id="footer-info" class="inner">
    
    &copy; 2024 Zachary<br>
    <!-- Powered by <a href="https://hexo.io/" target="_blank">Hexo</a> & Theme <a target="_blank" rel="noopener" href="https://github.com/saicaca/hexo-theme-vivia">Vivia</a> -->
      <a target="_blank" rel="noopener" href="https://beian.miit.gov.cn">苏ICP备20030005号-2</a>
  </div>
</footer>

    </div>
    <div class="back-to-top-wrapper">
    <button id="back-to-top-btn" class="back-to-top-btn hide" onclick="topFunction()">
        <i class="fa-solid fa-angle-up"></i>
    </button>
</div>

<script>
    function topFunction() {
        window.scroll({ top: 0, behavior: 'smooth' });
    }
    let btn = document.getElementById('back-to-top-btn');
    function scrollFunction() {
        if (document.body.scrollTop > 600 || document.documentElement.scrollTop > 600) {
            btn.classList.remove('hide')
        } else {
            btn.classList.add('hide')
        }
    }
    window.onscroll = function() {
        scrollFunction();
    }
</script>

  </div>
  <script src="/hexo-blog/js/light-dark-switch.js"></script>
</body>
</html>
